package com.example.administrator.yuejian23.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.yuejian23.Bean.Club;
import com.example.administrator.yuejian23.Fragment.viewholder.ClubInfoViewHolder;
import com.example.administrator.yuejian23.R;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on 2017/9/28.
 */

public class ClubInfoAdapter extends BaseAdapter {
    public ClubInfoAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View itemView = layoutInflater.inflate(R.layout.item_club_detail, parent, false);
        ClubInfoViewHolder viewHolder = new ClubInfoViewHolder(itemView);


        return viewHolder;
    }

    @Override
    void onBindVH(RecyclerView.ViewHolder holder, List data, int position) {
        final Club club = (Club) data.get(position);

        String address = "http://172.24.10.175/workout/Uploads/" + club.getThumb();
        if (holder instanceof ClubInfoViewHolder) {
            ClubInfoViewHolder viewHolder = (ClubInfoViewHolder) holder;
            String clubName =club.getClub_name();

            String intro = club.getIntroduction();
            String district_name = club.getDistrict_name();
            String open_time = club.getOpen_time();
            String phonenum = club.getClub_tel();

            viewHolder.clubNameView.setText(clubName);
            viewHolder.intro.setText(intro);
            viewHolder.open_time.setText(open_time);
            viewHolder.district_name.setText(district_name);
            viewHolder.phonenum.setText(phonenum);

            if (!club.getThumb().equals("")) {
                Picasso.with(context)
                        .load(address)
                        .into(ClubInfoViewHolder.imageView);
            }
        }
    }
}